import request from '@/utils/request'

export const findPage = (pageNum, pageSize, queryRequest) => {
  return request({
    url: `/admin/product/product/findPage/${pageNum}/${pageSize}`,
    method: 'get',
    params: queryRequest,
  })
}

/**
 *  获取所有品牌信息
 */
export const findBrandList = () => {
  return request({
    url: `/admin/product/brand/findAll`,
    method: 'get',
  })
}

/**
 *  获取子商品分类
 */
export const FindCategoryByParentId = id => {
  return request({
    url: `/admin/product/category/findByParentId/${id}`,
    method: 'get',
  })
}

/**
 *  获取单元列表
 */
export const findUnitList = () => {
  return request({
    url: `/admin/product/unit/findAll`,
    method: 'get',
  })
}

/**
 *  获取分类列表
 */
export const findSpecList = () => {
  return request({
    url: `/admin/product/productSpec/findAll`,
    method: 'get',
  })
}

/**
 *  添加商品
 */
export const SaveProduct = product => {
  return request({
    url: `/admin/product/product/saveProduct`,
    method: 'post',
    data: product,
  })
}

/**
 *  根据id获取商品
 */
export const getProductById = id => {
  return request({
    url: `/admin/product/product/getById/${id}`,
    method: 'get',
  })
}

/**
 *  修改商品
 */
export const updateProduct = product => {
  return request({
    url: `/admin/product/product/updateProduct`,
    method: 'put',
    data: product,
  })
}

/**
 *  根据id删除商品
 */
export const deleteProductById = id => {
  return request({
    url: `/admin/product/product/deleteProductById/${id}`,
    method: 'delete',
  })
}

/**
 *  商品下架
 */
export const takeoffProduct = id => {
  return request({
    url: `/admin/product/product/takeoffProduct/${id}`,
    method: 'put',
  })
}

/**
 *  商品上架
 */
export const takeonProduct = id => {
  return request({
    url: `/admin/product/product/takeonProduct/${id}`,
    method: 'put',
  })
}

/**
 *  商品审核
 */
export const auditProduct = (id, auditStatus) => {
  return request({
    url: `/admin/product/product/auditProduct/${id}/${auditStatus}`,
    method: 'put',
  })
}
